****
** Replication File:
**
** The Relationship between Social Media Use and 
** Beliefs in Conspiracy Theories and Misinformation
**
** 2020 June data
****

set more off

* Install cortesti
ssc install cortesti

* Set working directory

* Open June 2020 data
use "Clean Data, June 2020.dta"

********************************************************************************

****
** Table 3
****

* Non-COVID conspiracy beliefs
foreach v of var falseflag-deepstate{
	gen belief_`v' = 0
	replace belief_`v' = 1 if `v' > 3 & `v' < .
}

sum belief_falseflag-belief_deepstate

* COVID conspiracy beliefs
foreach v of var cpurpose-tracking{
	gen belief_`v' = 0
	replace belief_`v' = 1 if `v' > 3 & `v' < .
}

sum belief_cpurpose-belief_tracking

* COVID misinformation
foreach v of var hydroxy-uvlight{
	gen belief_`v' = 0
	replace belief_`v' = 1 if `v' > 3 & `v' < .
}

sum belief_hydroxy-belief_uvlight

********************************************************************************

****
** Figure 6 (stored in "Beliefs by Medium, June.csv")
****

mean gennumber if nattv == 1
mean gennumber if localtv == 1
mean gennumber if radio == 1
mean gennumber if newspaper == 1
mean gennumber if web == 1
mean gennumber if socmedia == 1  

ttesti 177 1.971751 1.663203 193 1.445596 1.593736
ttesti 177 1.971751 1.663203 58 1.551724 1.966138
ttesti 177 1.971751 1.663203 29 1.724138 1.509412
ttesti 177 1.971751 1.663203 273 1.450549 1.55722
ttesti 177 1.971751 1.663203 282 1.287234 1.541518

mean covnumber if nattv == 1
mean covnumber if localtv == 1
mean covnumber if radio == 1
mean covnumber if newspaper == 1
mean covnumber if web == 1
mean covnumber if socmedia == 1  

ttesti 177 1.898305 2.056267 193 1.165803 1.678129
ttesti 177 1.898305 2.056267 58 1.293103 1.982455
ttesti 177 1.898305 2.056267 29 1.517241 1.617332
ttesti 177 1.898305 2.056267 273 1.014652 1.638172
ttesti 177 1.898305 2.056267 282 1.056738 1.65868

mean misnumber if nattv == 1
mean misnumber if localtv == 1
mean misnumber if radio == 1
mean misnumber if newspaper == 1
mean misnumber if web == 1
mean misnumber if socmedia == 1  

ttesti 177 .9322034 1.259479 193 .7150259 1.179968
ttesti 177 .9322034 1.259479 58 .8965517 1.397864 
ttesti 177 .9322034 1.259479 29 1 1.101946
ttesti 177 .9322034 1.259479 273 .4542125 .9465061 
ttesti 177 .9322034 1.259479 282 .5992908 1.109198

********************************************************************************

****
** Figure 7 (stored in "Correlations, June.csv")
****

sem (<- gennumber facebook), standardize
sem (<- gennumber instagram), standardize
sem (<- gennumber twitter), standardize
sem (<- gennumber youtube), standardize

cortesti .3131242 1040 .2882143 1040
cortesti .3131242 1040 .3097904 1040

sem (<- covnumber facebook), standardize
sem (<- covnumber instagram), standardize
sem (<- covnumber twitter), standardize
sem (<- covnumber youtube), standardize

cortesti .1901183 1040 .253314 1040
cortesti .1901183 1040 .2560899 1040

sem (<- misnumber facebook), standardize
sem (<- misnumber instagram), standardize
sem (<- misnumber twitter), standardize
sem (<- misnumber youtube), standardize

********************************************************************************

****
** Table A6, marginal effects for Figure 8
** (stored in "Marginal Effects, June.csv")
****

reg gennumber socmedia conthink pid ideo edu interest age ///
	income female black hispanic	
est sto mod1
	
reg gennumber socialmedia socmedia conthink pid ideo interest edu age ///
	income female black hispanic		
est sto mod2
	
reg gennumber c.socialmedia##c.conthink c.socmedia##c.conthink pid ///
	ideo edu interest age income female black hispanic	
est sto mod3
margins, dydx(socialmedia) at(conthink=(1(.5)5))

* Save model estimates
esttab mod1 mod2 mod3 using "Conspiracy Estimates, June.rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: OLS coefficients with standard errors in parentheses)

****
** Table A7, marginal effects for Figure 8
** (stored in "Marginal Effects, June.csv")
****

reg covnumber socmedia conthink pid ideo interest edu age ///
	income female black hispanic	
est sto mod4	

reg covnumber socialmedia socmedia conthink pid ideo interest edu age ///
	income female black hispanic	
est sto mod5
	
reg covnumber c.socialmedia##c.conthink c.socmedia##c.conthink pid ///
	ideo  interest edu age income female black hispanic	
est sto mod6
margins, dydx(socialmedia) at(conthink=(1(.5)5))

* Save model estimates
esttab mod4 mod5 mod6 using "Covid Conspiracy Estimates, June.rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: OLS coefficients with standard errors in parentheses)

****
** Table A8, marginal effects for Figure 8
** (stored in "Marginal Effects, June.csv")
****

reg misnumber socmedia conthink pid ideo interest edu age ///
	income female black hispanic	
est sto mod7	

reg misnumber socialmedia socmedia conthink pid ideo interest edu age ///
	income female black hispanic	
est sto mod8	
	
reg misnumber c.socialmedia##c.conthink c.socmedia##c.conthink pid ///
	ideo interest edu age income female black hispanic	
est sto mod9	
margins, dydx(socialmedia) at(conthink=(1(.5)5))

* Save model estimates
esttab mod7 mod8 mod10 using "Misinformation Estimates, June.rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: OLS coefficients with standard errors in parentheses)

********************************************************************************

****
** Table A1
****

sum age, detail
sum income, detail
sum female
sum white
sum black
sum hispanic

****
** Table A2
****

sum pid
sum ideo 
sum attend	
	
********************************************************************************	
	
****
** Table A9 and estimates for Figure A2
** (stored in "Marginal Effects, June Tobit.csv")
****

tobit gennumber socmedia conthink pid ideo interest edu age ///
	income female black hispanic
est store mod11	
	
tobit gennumber socialmedia socmedia conthink pid ideo interest edu age ///
	income female black hispanic		
est store mod12	
	
tobit gennumber c.socialmedia##c.conthink c.socmedia##c.conthink pid ///
	ideo interest edu age income female black hispanic	
est store mod13	
margins, dydx(socialmedia) at(conthink=(1(.5)5))	

* Save model estimates
esttab mod11 mod12 mod13 using "Conspiracy Estimates, June (Tobit).rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: Tobit coefficients with standard errors in parentheses)
	
****
** Table A10 and estimates for Figure A2
** (stored in "Marginal Effects, June Tobit.csv")
****

tobit covnumber socmedia conthink pid ideo interest edu age ///
	income female black hispanic	
est store mod14	

tobit covnumber socialmedia socmedia conthink pid ideo interest edu age ///
	income female black hispanic	
est store mod15	
	
tobit covnumber c.socialmedia##c.conthink c.socmedia##c.conthink pid ///
	ideo interest edu age income female black hispanic
est store mod16	
margins, dydx(socialmedia) at(conthink=(1(.5)5))

* Save model estimates
esttab mod14 mod15 mod16 using "Covid Conspiracy Estimates, June (Tobit).rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: Tobit coefficients with standard errors in parentheses)

****
** Table A11 and estimates for Figure A2
** (stored in "Marginal Effects, June Tobit.csv")
****

tobit misnumber socmedia conthink pid ideo interest edu age ///
	income female black hispanic	
est store mod17	

tobit misnumber socialmedia socmedia conthink pid ideo interest edu age ///
	income female black hispanic
est store mod18	
	
tobit misnumber c.socialmedia##c.conthink c.socmedia##c.conthink pid ///
	ideo interest edu age income female black hispanic
est store mod19	
margins, dydx(socialmedia) at(conthink=(1(.5)5))	

* Save model estimates
esttab mod17 mod18 mod19 using "Misinformation Estimates, June (Tobit).rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: Tobit coefficients with standard errors in parentheses)
	
********************************************************************************

****
** Table A19
****

* Non-COVID conspiracy beliefs
alpha falseflag-deepstate, gen(conscale)

reg conscale c.socialmedia##c.conthink c.socmedia##c.conthink pid ///
	ideo edu interest age income female black hispanic	
est store mod20

* COVID conspiracy beliefs	
alpha cpurpose-tracking, gen(covidcon)

reg covidcon c.socialmedia##c.conthink c.socmedia##c.conthink pid ///
	ideo  interest edu age income female black hispanic	
est store mod21	

* COVID misinformation
alpha hydroxy-uvlight, gen(covidmisinfo)

reg covidmisinfo c.socialmedia##c.conthink c.socmedia##c.conthink pid ///
	ideo interest edu age income female black hispanic
est store mod22	

* Save model estimates
esttab mod20 mod21 mod22 using "Alternative Estimates 1, June.rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: Tobit coefficients with standard errors in parentheses)
	
********************************************************************************	
	
****
** Table A20
****		

* Non-COVID conspiracy beliefs
foreach v of var falseflag-deepstate{
	gen con_`v' = `v'
}	

reshape long con_, i(responseid) string j(whichcon)

mixed con_ c.socmedia##c.conthink c.socialmedia##c.conthink pid ideo ///
	interest edu age income female black hispanic || responseid:
est store mod23	
	
reshape wide	
	
* COVID conspiracy beliefs
foreach v of var cpurpose-tracking{
	gen covcon_`v' = `v'
}	

reshape long covcon_, i(responseid) string j(whichcovcon)

mixed covcon_ c.socmedia##c.conthink c.socialmedia##c.conthink pid ideo ///
	interest edu age income female black hispanic || responseid:
est store mod24	

* Save model estimates
esttab mod23 mod24 using "Alternative Estimates 2, June.rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: MLE coefficients with standard errors in parentheses)	

drop _est_mod24
reshape wide	
	
* COVID misinformation
foreach v of var hydroxy-uvlight{
	gen covmis_`v' = `v'
}	

reshape long covmis_, i(responseid) string j(whichmis)

mixed covmis_ c.socmedia##c.conthink c.socialmedia##c.conthink pid ideo ///
	interest edu age income female black hispanic || responseid:
est store mod25	
	
* Save model estimates
esttab mod25 using "Alternative Estimates 3, June.rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: Tobit coefficients with standard errors in parentheses)	

drop _est_mod25	
reshape wide
	
clear 
	
